package com.qf.hospital.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.hospital.entity.SysMenu;
import com.qf.hospital.mapper.SysMenuMapper;
import com.qf.hospital.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 何星宇
 * @version V1.0
 * @Date 2021/10/19 14:49
 */

@Service
public class SysMenuServiceImpl implements SysMenuService {
    @Autowired
    private SysMenuMapper mapper;

    /**
     * 查询所有菜单
     * @return
     */
    @Override
    public List<SysMenu> findAll() {
        List<SysMenu> sysMenuList = mapper.selectByExample(null);
        return sysMenuList;
    }

    /**
     * 根据条件查询菜单
     * @param id
     * @param title
     * @param page
     * @param limit
     * @return
     */
    @Override
    public PageInfo<SysMenu> findMenuByParentId(Integer id, String title, Integer page, Integer limit) {
        PageHelper.startPage(page, limit);

        List<SysMenu> sysMenuList = mapper.findMenuByParentId(id,title);
        PageInfo<SysMenu> pageInfo = new PageInfo<>(sysMenuList);
        return pageInfo;
    }
}
